package cn.itcast.mr.partition;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * Author itcast
 * Date 2021/10/17 10:00
 * Desc 自定义分区实现
 * 将彩票号大于 15 的放到一个分区中
 * 小于等于 15 发放到另外一个分区中
 */
public class MyPartitioner extends Partitioner<IntWritable, Text> {
    @Override
    public int getPartition(IntWritable intWritable, Text text, int numPartitions) {
        int caipiaoCode = intWritable.get();
        if (caipiaoCode > 15) {
            return 0;
        } else {
            return 1;
        }
    }
}
